package com.ovo.rxandroiddemo.utils;

import android.content.Context;
import android.view.View;
import android.view.inputmethod.InputMethodManager;

import com.ovo.rxandroiddemo.app.BaseApplication;

/***
 * 软键盘隐藏显示
 */
public class SoftInputUtils {
    public static void hideKeyboard() {
        InputMethodManager imm = (InputMethodManager) BaseApplication.activity.getSystemService(Context.INPUT_METHOD_SERVICE);
        if (imm.isActive()){
            imm.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS);
        }
    }

    public static void hideKeyboard(View v) {
        InputMethodManager imm = (InputMethodManager) v.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
        if (imm.isActive()) {
            imm.hideSoftInputFromWindow(v.getApplicationWindowToken(), 0);

        }
    }
}
